import { request_post, request_get, request_put, request_delete } from 'services/common/request';
import pathToRegexp from 'path-to-regexp';
let toPathGroup = pathToRegexp.compile('/api/data_articles/groups/:id');
/**
 * 赛事实时监控列表
 * @param {Object} data
 * @param {String} data.name - 选填 名称
 * @param {String} data.pageStart
 * @param {String} data.pageOffset
 * @param {String} data.pageNum
 */
export function getList(data = {}) {
	return request_get('/race/raceList', data);
}

/**
 * 赛事列表删除
 * @param {Object} data
 * @param {String} data.name - 选填 名称
 * @param {String} data.username
 * @param {String} data.password
 */
export function del(data = {}) {
	return request_post('/race/delete', data);
}

/**
 * 返回赛事实时监控列表
 * @param {Object} data
 * @param {String} data.raceId - 选填 赛事id
 */
export function realTimeList(data = {}) {
	return request_get('/race/realTimeList', data);
}

/**
 * 根据赛事id查询从赛事开始时间到结束时间段内每日人次列表
 * @param {Object} data
 * @param {String} data.raceId - 选填 赛事id
 */
export function everydayList(data = {}) {
	return request_get('/race/everydayList', data);
}

/**
 * 返回赛事当日运动人数趋势图
 * @param {Object} data
 * @param {String} data.raceId - 选填 赛事id
 */
export function trendList(data = {}) {
	return request_get('/race/trendList', data);
}

/**
 * 返回赛事当日运动人数趋势图
 * @param {Object} data
 * @param {String} data.raceId - 选填 赛事id
 */
export async function getAllInfo(data = {}) {
	const { data: trendList } = await request_get('/race/trendList', data);
	const { data: everydayList } = await request_get('/race/everydayList', data);
	const { data: realTimeList } = await request_get('/race/realTimeList', data);
	return {
		trendList,
		everydayList,
		realTimeList
	};
}
